
String.prototype.bLength = function() {
     var arr = this.match(/[^\x00-\xff]/ig);
     return  arr == null ? this.length : this.length + arr.length;
}

var Common = {
    
    gotoUrl: function(url){
        window.location = url;
    },

    submit: function(){
    	$("form").submit();
    },

    showDialog: function(config){
        var dialogId = config.dataDiv;
        var data = "";
        if(config.data){
            data = config.data;
        }
        var url = config.url;
        var height = config.height;
        var width = config.width;
        //init dialog
        $("#" + dialogId).dialog({
                        modal: true ,
                        height: height ,
                        autoOpen: false,
                        width: width,
                        resizable: false,
                        overlay: {
                           opacity: 0.6,
                           background: "#555555"
                        },
                        close: function(event, ui) {
                            $("#" + dialogId).dialog( 'destroy' );
                        }
        });
        //get html content from server
        $.ajax({
            type:"POST",
            async:false,
            url:url,
            data: data,
            dataType:"Html",
            success:function(responseText){
                $("#" + dialogId).empty();
                $("#" + dialogId).html(responseText);
                $("#" + dialogId).dialog("open");
            }
        });
    },

    closeDialog: function(dialogId){
        $("#" + dialogId).empty();
        $("#" + dialogId).dialog("close");
    },

    deleteItem : function(url){
        if(jConfirm('Are you sure you want to do this?')){
            Common.gotoUrl(url);
        }
    },
    
    deleteSubmit : function(url){
    	if(confirm('确定删除吗？')){
    		Common.gotoUrl(url);
    	}
    }
}